package com.tbi.graphcolouring.testers;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class ColorsNormalizationTest {

	public static void main(String[] args) {
		int[] a = {21, 23, 18, 8, 23, 16, 15, 18, 16, 5, 6, 2, 8, 7, 23, 23, 14, 11, 18, 23, 19, 19, 14, 11, 9};
		System.out.println("Before normalization: "+Arrays.toString(a));
		normalize(a);
		System.out.println("After normalization : "+Arrays.toString(a));
	}
	
	private static void normalize(int[] colors) {
		Map<Integer, Integer> colorMapper = new HashMap<Integer, Integer>();
		for (int i = 0; i < colors.length; i++) {
			if(!colorMapper.containsKey(colors[i])){
				colorMapper.put(colors[i], colorMapper.size());
			}
		}
		for (int i = 0; i < colors.length; i++) {
			colors[i] = colorMapper.get(colors[i]);
		}
	}

}
